using log4net;
using log4net.Config;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
public sealed class frmBlackLists : Form
{
	private IContainer icontainer_0;
	private DataGridView dataGridView1;
	private Button btnClose;
	private Button btnDelete;
	private Button btnAdd;
	private Button btnEdit;
	private DataGridViewTextBoxColumn STT;
	private DataGridViewTextBoxColumn PlateNumberColumn;
	private DataGridViewTextBoxColumn NameColumn;
	private DataGridViewTextBoxColumn AddressColumn;
	private DataGridViewTextBoxColumn DescriptionColumn;
	private bool bool_0 = true;
	private ILog ilog_0 = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
	public frmBlackLists()
	{
		this.InitializeComponent();
		BasicConfigurator.Configure();
		XmlConfigurator.Configure();
	}
	protected override void Dispose(bool disposing)
	{
		if (disposing && this.icontainer_0 != null)
		{
			this.icontainer_0.Dispose();
		}
		base.Dispose(disposing);
	}
	private void InitializeComponent()
	{
		this.dataGridView1 = new DataGridView();
		this.STT = new DataGridViewTextBoxColumn();
		this.PlateNumberColumn = new DataGridViewTextBoxColumn();
		this.NameColumn = new DataGridViewTextBoxColumn();
		this.AddressColumn = new DataGridViewTextBoxColumn();
		this.DescriptionColumn = new DataGridViewTextBoxColumn();
		this.btnClose = new Button();
		this.btnDelete = new Button();
		this.btnAdd = new Button();
		this.btnEdit = new Button();
		((ISupportInitialize)this.dataGridView1).BeginInit();
		base.SuspendLayout();
		this.dataGridView1.AllowUserToAddRows = false;
		this.dataGridView1.AllowUserToDeleteRows = false;
		this.dataGridView1.AllowUserToResizeRows = false;
		this.dataGridView1.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
		this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
		this.dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
		this.dataGridView1.Columns.AddRange(new DataGridViewColumn[]
		{
			this.STT,
			this.PlateNumberColumn,
			this.NameColumn,
			this.AddressColumn,
			this.DescriptionColumn
		});
		this.dataGridView1.Location = new System.Drawing.Point(13, 13);
		this.dataGridView1.Margin = new Padding(4);
		this.dataGridView1.Name = "dataGridView1";
		this.dataGridView1.ReadOnly = true;
		this.dataGridView1.RowHeadersVisible = false;
		this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
		this.dataGridView1.Size = new System.Drawing.Size(870, 413);
		this.dataGridView1.TabIndex = 1;
		this.dataGridView1.CellDoubleClick += new DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick);
		this.dataGridView1.CellMouseDown += new DataGridViewCellMouseEventHandler(this.dataGridView1_CellMouseDown);
		this.STT.HeaderText = "STT";
		this.STT.Name = "STT";
		this.STT.ReadOnly = true;
		this.STT.Width = 60;
		this.PlateNumberColumn.HeaderText = "Biển số";
		this.PlateNumberColumn.Name = "PlateNumberColumn";
		this.PlateNumberColumn.ReadOnly = true;
		this.NameColumn.HeaderText = "Họ tên";
		this.NameColumn.Name = "NameColumn";
		this.NameColumn.ReadOnly = true;
		this.NameColumn.Width = 200;
		this.AddressColumn.HeaderText = "Địa chỉ";
		this.AddressColumn.Name = "AddressColumn";
		this.AddressColumn.ReadOnly = true;
		this.AddressColumn.Width = 250;
		this.DescriptionColumn.HeaderText = "Ghi chú";
		this.DescriptionColumn.Name = "DescriptionColumn";
		this.DescriptionColumn.ReadOnly = true;
		this.DescriptionColumn.Width = 255;
		this.btnClose.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
		this.btnClose.Location = new System.Drawing.Point(770, 434);
		this.btnClose.Margin = new Padding(4);
		this.btnClose.Name = "btnClose";
		this.btnClose.Size = new System.Drawing.Size(113, 34);
		this.btnClose.TabIndex = 35;
		this.btnClose.Text = "Đóng";
		this.btnClose.UseVisualStyleBackColor = true;
		this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
		this.btnDelete.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
		this.btnDelete.Enabled = false;
		this.btnDelete.Location = new System.Drawing.Point(257, 434);
		this.btnDelete.Margin = new Padding(4);
		this.btnDelete.Name = "btnDelete";
		this.btnDelete.Size = new System.Drawing.Size(113, 34);
		this.btnDelete.TabIndex = 34;
		this.btnDelete.Text = "Xóa";
		this.btnDelete.UseVisualStyleBackColor = true;
		this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
		this.btnAdd.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
		this.btnAdd.Location = new System.Drawing.Point(15, 434);
		this.btnAdd.Margin = new Padding(4);
		this.btnAdd.Name = "btnAdd";
		this.btnAdd.Size = new System.Drawing.Size(113, 34);
		this.btnAdd.TabIndex = 33;
		this.btnAdd.Text = "Thêm";
		this.btnAdd.UseVisualStyleBackColor = true;
		this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
		this.btnEdit.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
		this.btnEdit.Enabled = false;
		this.btnEdit.Location = new System.Drawing.Point(136, 434);
		this.btnEdit.Margin = new Padding(4);
		this.btnEdit.Name = "btnEdit";
		this.btnEdit.Size = new System.Drawing.Size(113, 34);
		this.btnEdit.TabIndex = 32;
		this.btnEdit.Text = "Sửa";
		this.btnEdit.UseVisualStyleBackColor = true;
		this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click);
		base.AutoScaleDimensions = new System.Drawing.SizeF(8f, 16f);
//		base.AutoScaleMode = AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(896, 477);
		base.Controls.Add(this.btnClose);
		base.Controls.Add(this.btnDelete);
		base.Controls.Add(this.btnAdd);
		base.Controls.Add(this.btnEdit);
		base.Controls.Add(this.dataGridView1);
		this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
//		base.FormBorderStyle = FormBorderStyle.FixedDialog;
		base.Margin = new Padding(4);
		base.Name = "frmBlackLists";
		base.StartPosition = FormStartPosition.CenterScreen;
		this.Text = "Danh sách xe BlackList";
		base.Load += new System.EventHandler(this.frmBlackLists_Load);
		((ISupportInitialize)this.dataGridView1).EndInit();
		base.ResumeLayout(false);
	}
	public bool method_0()
	{
		return this.bool_0;
	}
	public void method_1(bool bool_1)
	{
		this.bool_0 = bool_1;
	}
	private void btnAdd_Click(object sender, System.EventArgs e)
	{
		frmBlackList frmBlackList = new frmBlackList();
		while (frmBlackList.ShowDialog() == DialogResult.OK)
		{
            BO1 gClass = MainForm.SystemConfiguration_0.gclass4_0.Search(frmBlackList.method_0());
			if (gClass != null)
			{
				if (gClass.method_12())
				{
					MessageBox.Show("Đã tồn tại biển số này trong danh sách xe đen.\nHãy nhập biển số = khác.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				}
				else
				{
					if (gClass.method_14())
					{
						MessageBox.Show("Đã tồn tại biển số này trong danh sách xe đặc biệt.\nHãy nhập biển số = khác.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
					}
				}
			}
			else
			{
                BO1 gClass2 = new BO1();
				gClass2.method_1(MainForm.SystemConfiguration_0.int_25++);
				gClass2.method_3(frmBlackList.method_0());
				gClass2.method_5(frmBlackList.method_2());
				gClass2.method_9(frmBlackList.method_4());
				gClass2.method_17(frmBlackList.method_6());
				gClass2.method_13(this.bool_0);
				gClass2.method_15(!this.bool_0);
				if (!MainForm.SystemConfiguration_0.method_24(gClass2))
				{
					break;
				}
				if (this.bool_0)
				{
					this.method_2();
					this.ilog_0.Info("Add BlackListVehicle: " + gClass2.method_2());
					return;
				}
				this.method_3();
				this.ilog_0.Info("Add SpecialListVehicle: " + gClass2.method_2());
				break;
			}
		}
	}
	private void frmBlackLists_Load(object sender, System.EventArgs e)
	{
		if (this.bool_0)
		{
			this.Text = "Danh sách xe đen";
			this.BackColor = System.Drawing.Color.DarkGray;
			this.method_2();
			return;
		}
		this.Text = "Danh sách xe đặc biệt";
		this.BackColor = System.Drawing.Color.LightPink;
		this.method_3();
	}
	private void method_2()
	{
		this.dataGridView1.Rows.Clear();
		int num = 0;
        foreach (BO1 gClass in MainForm.SystemConfiguration_0.gclass4_0)
		{
			if (gClass.method_12())
			{
				num++;
				this.dataGridView1.Rows.Add(new object[]
				{
					num.ToString(),
					gClass.method_2(),
					gClass.method_4(),
					gClass.method_8(),
					gClass.method_16()
				});
			}
		}
		if (this.dataGridView1.RowCount > 0)
		{
			this.dataGridView1.CurrentCell = this.dataGridView1[0, this.dataGridView1.RowCount - 1];
		}
		this.btnEdit.Enabled = (this.btnDelete.Enabled = (this.dataGridView1.RowCount > 0));
	}
	private void method_3()
	{
		this.dataGridView1.Rows.Clear();
		int num = 0;
        foreach (BO1 gClass in MainForm.SystemConfiguration_0.gclass4_0)
		{
			if (gClass.method_14())
			{
				num++;
				this.dataGridView1.Rows.Add(new object[]
				{
					num.ToString(),
					gClass.method_2(),
					gClass.method_4(),
					gClass.method_8(),
					gClass.method_16()
				});
			}
		}
		if (this.dataGridView1.RowCount > 0)
		{
			this.dataGridView1.CurrentCell = this.dataGridView1[0, this.dataGridView1.RowCount - 1];
		}
		this.btnEdit.Enabled = (this.btnDelete.Enabled = (this.dataGridView1.RowCount > 0));
	}
	private void btnEdit_Click(object sender, System.EventArgs e)
	{
		if (this.dataGridView1.RowCount > 0)
		{
			string string_ = this.dataGridView1.CurrentRow.Cells["PlateNumberColumn"].Value.ToString();
            BO1 gClass = MainForm.SystemConfiguration_0.gclass4_0.Search(string_);
			if (gClass != null)
			{
				frmBlackList frmBlackList = new frmBlackList();
				frmBlackList.method_3(gClass.method_4());
				frmBlackList.method_1(gClass.method_2());
				frmBlackList.method_5(gClass.method_8());
				frmBlackList.method_7(gClass.method_16());
				while (frmBlackList.ShowDialog() == DialogResult.OK)
				{
					if (frmBlackList.method_0() != gClass.method_2())
					{
                        BO1 gClass2 = MainForm.SystemConfiguration_0.gclass4_0.Search(frmBlackList.method_0());
						if (gClass2 != null)
						{
							if (gClass2.method_12())
							{
								MessageBox.Show("Đã tồn tại biển số này trong danh sách xe đen.\nHãy nhập biển số = khác.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
								continue;
							}
							if (gClass2.method_14())
							{
								MessageBox.Show("Đã tồn tại biển số này trong danh sách xe đặc biệt.\nHãy nhập biển số = khác.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
								continue;
							}
							continue;
						}
					}
					if (!MainForm.SystemConfiguration_0.method_25(gClass, frmBlackList.method_0(), frmBlackList.method_2(), string.Empty, frmBlackList.method_4(), 0, this.bool_0, !this.bool_0, frmBlackList.method_6()))
					{
						break;
					}
					if (this.bool_0)
					{
						this.method_2();
						this.ilog_0.Info("Edit BlackListVehicle: " + gClass.method_2());
						return;
					}
					this.method_3();
					this.ilog_0.Info("Edit SpecialListVehicle: " + gClass.method_2());
					break;
				}
			}
		}
	}
	private void btnDelete_Click(object sender, System.EventArgs e)
	{
		if (this.dataGridView1.RowCount > 0)
		{
			string string_ = this.dataGridView1.CurrentRow.Cells["PlateNumberColumn"].Value.ToString();
            BO1 gClass = MainForm.SystemConfiguration_0.gclass4_0.Search(string_);
			if (gClass != null && MessageBox.Show("Bạn có thực sự muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes && MainForm.SystemConfiguration_0.method_26(gClass))
			{
				if (this.bool_0)
				{
					this.method_2();
					this.ilog_0.Info("Delete BlackListVehicle: " + gClass.method_2());
					return;
				}
				this.method_3();
				this.ilog_0.Info("Delete SpecialListVehicle: " + gClass.method_2());
			}
		}
	}
	private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
	{
		if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
		{
			this.btnEdit_Click(null, null);
		}
	}
	private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
	{
		if (e.RowIndex >= 0)
		{
			this.dataGridView1.CurrentCell = this.dataGridView1[0, e.RowIndex];
		}
	}
	private void btnClose_Click(object sender, System.EventArgs e)
	{
		base.Close();
	}
}
